// pages/continue/index.js
var util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    recordInfo: '',
    price: '',
    desc: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    this.data.recordInfo = options;

  },
  priceInput(e) {
    console.log(this.data.recordInfo.price)
    // if (Number(e.detail.value) > Number(this.data.recordInfo.price)) {
    //   console.log(1)
    //   this.setData({
    //     price: this.data.recordInfo.price
    //   })
    // } else {
    //   this.setData({
    //     price: e.detail.value
    //   })
    // }
    this.setData({
      price: e.detail.value
    })
  },
  descInput(e) {
    this.setData({
      desc: e.detail.value
    })
  },

  onSubmit() {
    console.log(1)
    let that = this
    if (this.data.price == 0 || this.data.price === '') {
      wx.showToast({
        title: '输入金额有误',
        icon: 'none',
        duration: 2000
      })
      return false;
    }
    if (this.data.desc === '') {
      wx.showToast({
        title: '输入反馈为空',
        icon: 'none',
        duration: 2000
      })
      return false;
    }
    util.http({
      url: 'api/miniwechat/order/consult',
      method: 'POST',
      data: {
        user_id: this.data.recordInfo.userId,
        record_id: this.data.recordInfo.recordId,
        refund_money: this.data.price,
        refund_content: this.data.desc
      }
    }).then(res => {
      wx.showToast({
        title: '发送成功',
        icon: 'none',
        duration: 1000
      })
      setTimeout(() => {
        wx.navigateBack({
          delta: 1
        })
      }, 1000)
      }).catch(err => {
      wx.showToast({
        title: String(err),
        icon: 'none',
        duration: 2000
      })
    })
  },
  
})